<?php
  header("Content-type: text/html; charset=utf-8"); 
  header("Content-type:application/vnd.ms-excel");  //设置内容类型
  header("Content-Disposition:attachment;filename=data.xls");  //文件下载
  include_once('classes/user/user.class.php');
  include_once('classes/depart/depart.class.php'); 
  include_once('classes/addtime/time.class.php');
  $user = new user();
  $depart = new depart();
  $time = new time();
  $department = $_GET['name'];
  $date = $_GET['month'];
  if($department!='all') {
	  $depart_one = $depart->get_one_depart($department,'d_name');
	  $user_depart = $user->get_all_user($where='d_id="'.$depart_one['d_id'].'"');
  }else {
	        $user_depart = $user->get_all_user();
  }
  $dep = $depart->get_all_depart();
?>
<html xmlns:o="urn:schemas-microsoft-com:office:office" 
 xmlns:x="urn:schemas-microsoft-com:office:excel" 
 xmlns="http://www.w3.org/TR/REC-html40"> 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 <html> 
     <head> 
        <meta http-equiv="Content-type" content="text/html;charset=UTF-8" /> 
         <style id="Classeur1_16681_Styles"></style> 
     </head> 
     <body> 
         <div id="Classeur1_16681" align=center x:publishsource="Excel"> 
             <table x:str border=0 cellpadding=0 cellspacing=0 width=100% style="border-collapse: collapse"> 
				 <tr>
					 <td>部门</td>
					 <td>姓名</td> 
					 <td>加班月份</td>
					 <td>加班个数</td>
				 </tr>
				<?php
				$date=$_GET['month'];
				for($n=0; $n<count($user_depart); $n++)
				{
					$jb = $time->get_all_time($where=' u_id="'.$user_depart[$n]['u_id'].'"AND a_month="'.$date.'"');
					for($m=0;$m<count($jb);$m++) {
				?>
				<tr>
					<td><?php $depthis = $depart->get_one_depart($user_depart[$n]['d_id'],'d_id');
							  echo $depthis['d_name'];?></td>
					<td><?php echo $user_depart[$n]['u_user']?></td>
					<td><?php echo $jb[$m]['a_month']?></td>
					<td><?php echo $jb[$m]['a_day']?></td>
				</tr>
				<?php
					}
				}
				?>
             </table> 
         </div> 
     </body> 
 </html>